package com.blackline.auto.Report;

import static org.junit.Assert.fail;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

import com.blackline.auto.common.CommonMethods;
import com.blackline.declareUI.UI;
import com.blackline.parameters.Parameters;
import com.blackline.parameters.TestData;

/**
 * 			Testing environment: T2
 * 			Instance: Test 2
 *          This is to run a single standard report with name User Role Assignemnts
 */

public class C39967_CertificationLogReportingFormatting {
	private WebDriver driver;
	private StringBuffer verificationErrors = new StringBuffer();
	private static Logger logger=Logger.getLogger(C39967_CertificationLogReportingFormatting.class);
	UI UI=new UI();
	int sleepTime= 2000;
	Parameters parameters;
	int i=0;
	String NameofReport;
	

	@Before
	public void setUp() throws Exception {
		
		
		FirefoxProfile profile=new FirefoxProfile();
		profile.setEnableNativeEvents(true);
		parameters=new Parameters("parameters.xml");
		driver=new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		driver.manage().window().maximize();
		UI.declareAllUI(driver);	
	}

	@After
	public void tearDown() throws Exception
	{
		CommonMethods.takeScreenShot(this.getClass(), driver);
		driver.quit();
		
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString))
		{
			fail(verificationErrorString);
		}
	}

	/**
	 * This is to all reports from Report Log
	 * Filters 'Failed' Reports and on the basis of 'Start Date' and 'End Date'
	 * 
	 */
	@Test
	public void testDeleteFailedReports() throws Exception
	{
		logger.info("You've selected site: "+parameters.getSite("urlt2T3"));
		UI.LogonPage.Login(driver, parameters.getSite("urlt2T3"), parameters.getLogonID("admin"), parameters.getPassword("admin"));
		Thread.sleep(sleepTime);
		
		//Go to Reports link
		UI.NavigationMenu.REPORTS.click();
	}
}
